<template>
  <div>
    <div class="header-wrap">
      <Header />
      <Search :cities="cities" />
    </div>
    <List :cities="cities" :hotCities="hotCities" />
    <Alphabet :cities="cities" />
  </div>
</template>

<script>
import Header from './components/Header'
import Search from './components/Search'
import List from './components/List'
import Alphabet from './components/Alphabet'

import { get } from '../../utils/http'

export default {
  components: { Header, Search, List, Alphabet },

  name: 'City',
  data() {
    return {
      cities: {},
      hotCities: [],
    }
  },
  methods: {
    getCityData() {
      get('./api/city.json').then(this.getCityDataSucc)
    },

    getCityDataSucc(res) {
      res = res.data
      if (res.ret && res.data) {
        // console.log(res.data)
        this.cities = res.data.cities
        this.hotCities = res.data.hotCities
      }
    },
  },

  mounted() {
    this.getCityData()
  },
}
</script>

<style lang="scss" scoped>
.header-wrap {
  width: 100%;
  position: fixed;
  z-index: 99;
  height: auto;
}
</style>
